Bug in load_scripts and load_styles
-
I noticed an odd error on WP pages after installing this plugin. When the plugin loads the styles and script on frontend it also included a weird CSS and JS files with src=”https://h?ver=3.1.9″ but with no content. And because the src was like that it didn’t load anything but while trying delayed loading everything else.
A little digging later I found the load_styles & load_scripts functions in includes/assets.php. These functions check if the $v[‘src’] is empty or if the $v is a string and somehow it let through the strings as arrays, took only the first letter as src and created the oddities in the html head.
I got it fixed by adding a is_array to the if clause.
So this was the if clause before, starting on lines 209 and 248 on includes/assets.php
if ( ! empty( $v['src'] ) ) { // array with src in $v['src'] } elseif ( is_string( $v ) && ! empty( $v ) ) { // string as direct src in $v }
And this what I changed those to:
if ( is_array($v) && !empty( $v['src'] ) ) { // array with src in $v['src'] } elseif ( is_string( $v ) && ! empty( $v ) ) { // string as direct src in $v }
With this modification the page loads 3-5 seconds faster as there is nothing blocking to load other resources.
I don’t know if this is a common bug but it could be corrected in the future versions to be more foolprood.
- The topic ‘Bug in load_scripts and load_styles’ is closed to new replies.