Defer parsing of javascript to improve performance in wordpress

Nothing for introduction, hehe! A very small snippet which will help you to defer parsing all javascript files except jquery in wordpress. Here is the code: This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters Show hidden characters <?php function defer_parsing_of_js ( $url ) { if ( FALSE === strpos( $url, '.js' ) ) return $url; if ( strpos( $url, 'jquery.js' ) ) return $url; return "$url' defer "; } add_filter( 'clean_url', 'defer_parsing_of_js', […]

Continue Reading

You may also like

How to get start date of a week in JavaScript

This is little tricky to get the start date or/and end date of a week. Also, there is no standard day that should be a REAL start day in a week. In my example, I assume that the start day is Monday. Also, I will show you how you can adjust it to fit your needs. So, you can make it as Saturday or Sunday or whatever. In my example, suppose I want to make a title like “Accepting Bookings For the Week of START_DATE to END_DATE”. So, within this week, it should be same. But in next week, it […]

Continue Reading

You may also like

Redirect to another page when back button is pressed in JavaScript

One of the most wanted feature now-a-days is to detect browser back button. Couple of years ago there were lots of script to detect browser’s back button, but browsers are getting smarter day by day, and so are we Sometimes we need to redirect into a different page when user press browser back button. So, we need to detect when the user press back button. Well a developer Brooke Bryan wrote a script for detecting pressing back button. You will found the script here. But it will detect back button and then redirect to old page. I have modified the […]

Continue Reading

You may also like