My wife has to watch some videos as part of an online course. These videos do not have speed controls, however she would like to watch the video at an increased rate (e.g. 1.5x the normal speed). The problem is the video appears in an iframe (which is in itself in an iframe) so targeting the video to change the speed with JavaScript is a little tricky. Here is how I did it.
JavaScript
WordPress JavaScript async defer
When loading JavaScript on a webpage with the “script” tag, there are additional attributes you can add to tell the browser how and when to load the JavaScript (‘async’ and ‘defer’). In WordPress, there is not a native way to add these attributes but this code snippet does the trick.
Introduction to Arrow functions
I’ve been spending more time working with modern JavaScript (including learning about arrow functions) and I wanted to make some notes here regarding arrow functions (since some details about them were not intuitive to me at first).
Why Learn jQuery
A friend of mine, who is not a developer by trade but deals with websites a lot, asked me recently about learning JavaScript. The short version of my recommendation is to learn jQuery. It is already installed on the sites he is working on and using it he can get results quickly.
Detect when Native HTML5 Video Finishes Playing
On a recent project, I had to trigger a certain behavior when a native HTML5 video had completed playing (i.e. reached the end of the video, manually stopping it should not trigger the behavior).
JavaScript Idle Detection
Recently, I needed to determine when a website visitor was idle for a certain amount of time. I thought this was an interesting problem and wanted to spend a little more time with JavaScript so I wrote some code for it.
JavaScript Distance Between Two Locations
When working with locations in JavaScript, you often have two sets of latitude/longitude coordinates and you need the distance between theme. This function will give you an approximate distance between theme (in miles by default).
WordPress Development Overlay
When doing WordPress theme development I find it helpful to overlay an image of the approved design on top of the code I’m working on. I use a reduced opacity on the image so I can see the code I’m working on. This helps me match things like font size and spacing. I’ve been doing […]
WordPress sanitize_title() in JavaScript
I was working on a project where I needed the functionality provided by the WordPress PHP function sanitize_title(). Unfortunately, I needed this functionality in JavaScript. As with many problems in programming, this turned out to be more complex than I originally thought it would be. I discovered there were a number of edge-cases that I […]
wp_localize_script Explanation
A long time ago a WordPress programmer wanted to use a PHP value in their JavaScript. No problem they said, I’ll add this in my PHP theme code. Using a PHP Value in JavaScript – version 1 <?php $my_php_value = ‘Hello World’; echo ‘<script>’; echo ‘alert( “‘ . $myPHPValue . ‘” );’; echo ‘</script>’; ?> […]