Defer JS [Deleted]

Jeremy P

XenForo developer
Staff member
Jeremy P submitted a new resource:

Defer JS - Moves XenForo javascripts to before the </body> tag for performance

This addon collects javascript in post-view output and moves them to the bottom of the page. This has a noticeable impact on page-load times as pending HTTP requests postpone rendering of a page.

Much of the heavy lifting was derived (with permission) from @Luke Foreman's XFOptimise addon, which is no longer maintained.

Read more about this resource...
 
be careful if installing this. Tried installing this with the auto installer and and this was the error i received "
Parse error: syntax error, unexpected '[' in /home/xxx/public_html/www.xyz.com/library/Jrahmy/DeferJs/Defer.php on line 56"

Furthermore my site is now offline and says the following when i try to go there:
"Parse error: syntax error, unexpected '[' in /home/xxx/public_html/www.xyz.com/library/Jrahmy/DeferJs/Defer.php on line 56"

@Jeremy P ??
 
This requires PHP 5.4+ as stated in the requirements section. Disable listeners via config.php then uninstall and delete the addon.
 
be careful if installing this. Tried installing this with the auto installer and and this was the error i received "
Parse error: syntax error, unexpected '[' in /home/xxx/public_html/www.xyz.com/library/Jrahmy/DeferJs/Defer.php on line 56"

Furthermore my site is now offline and says the following when i try to go there:
"Parse error: syntax error, unexpected '[' in /home/xxx/public_html/www.xyz.com/library/Jrahmy/DeferJs/Defer.php on line 56"

@Jeremy P ??
Maybe it's not designed for installation with auto installer?

On side note, what is the meaning of admin.php?options/list/jrahmy_deferJs
 
Maybe it's not designed for installation with auto installer?

On side note, what is the meaning of admin.php?options/list/jrahmy_deferJs

Per the description:
Enter a unique string of text from any script tags which should not be moved. One per line.

If one of the lines entered there is found in an inline javascript or script URL it will not be moved to the bottom of the page. For example if the default ad settings were not here it would move advertisements which would otherwise be a nasty side effect.
 
Works with Waindigo's Install and Upgrade. Thank you! Guess I'll do a GTMetrix test. Not sure if possible from my phone but I'll give it a shot.
 
This requires PHP 5.4+ as stated in the requirements section. Disable listeners via config.php then uninstall and delete the addon.
I have this working in PHP 5.3.

Unless I've overlooked something, the only thing that isn't PHP 5.3 compatible is your array syntax. You're using the relatively new array shorthand.

So you're using:
PHP:
[$this, 'collect']
Instead of:
PHP:
array ($this, 'collect')

In my testing, I have just adjusted the array syntax and it appears to be working fine.

upload_2014-3-14_9-8-16.webp

upload_2014-3-14_9-8-37.webp
 
wow great addon but there is small problem =(

its take all java script to the bottom + the advertisement code also =(

see this

upload_2014-3-14_13-38-59.webp

so is there way to make an exclude for some code like but an if statements for them or something else =(

waiting ur replay
 
Will this help defer parsing of javscript seen here when testing of my site being poor in this area?

Yup, as much as possible. Depends on the site but you can generally expect modest improvements.

wow great addon but there is small problem =(

its take all java script to the bottom + the advertisement code also =(
Check out the options ;)
Enter a string from the ad code and it will skip over it.
 
Yup, as much as possible. Depends on the site but you can generally expect modest improvements.


Check out the options ;)
Enter a string from the ad code and it will skip over it.

same thing

this is my code

Code:
<!-- Begin Hsoub Ads Ad Place code -->
<script type="text/javascript"><!--
hsoub_adplace = xxxxxxxx;
hsoub_adplace_size = '160x600';
//--></script>
<script src="http://ads2.hsoub.com/show.js" type="text/javascript"></script>
<!-- End Hsoub Ads Ad Place code -->

in the option i tried

hsoub
hsoub_adplace

nothing change =(
 
Unless I've overlooked something, the only thing that isn't PHP 5.3 compatible is your array syntax. You're using the relatively new array shorthand.
Yeah. The filesums contains an array so you'll want to patch that too.

I couldn't find a Linux distro with a pre 5.4 PHP in the latest stable version, so I'm not really interested in maintaining compatibility with prior versions.
 
How do you know how to properly set this up with ease or must you have coding knowledge. Do you want google ads bypassed I guess? Is there anything else needing bypassing to function properly?

Thanks
 
How do you know how to properly set this up with ease or must you have coding knowledge. Do you want google ads bypassed I guess? Is there anything else needing bypassing to function properly?

Thanks
Adsense (and Adbrite? I think) are bypassed by default for the most common setups. Unless you have a funky addon or different ad vendor you should be good. If something isn't working I'd be happy to take a look.
 
Back
Top Bottom