Defer JS [Deleted]

Webmaster Tools? Or Analytics? I use Webmaster tools but I've never had to verify it with any code.

In any case, just use the blacklist. That's what it's there for.
 
Webmastertools and analytics are tightly knit at google. And to use webmaster tools your site has to be verified.

The recommended from google is asynchronous snippet in your head tag
https://support.google.com/webmasters/answer/35179?hl=en
Verification is the process of proving that you own the site or app that you claim to own. We need to confirm ownership because once you are verified for a site or app you have access to its private Google Search data, and can affect how Google Search crawls it.

...
If you use Google Analytics to track your site's traffic, you can verify your site using the Google Analytics tracking code associated with the site. To do this, you must have "edit" permission for the web property whose tracking code is used by that page. Also, your tracking code must use the new asynchronous snippet.

To verify ownership using Google Analytics, choose Google Analytics in the verification details page for your site, and follow the instructions shown.

When copying Google Analytics code:
Put the tracking code in the <head> section, not the <body> section, of your page. If you do not, verification will fail.

That said, I was unaware of the blacklist option available. I had only recently installed your mod and hadnt reviewed the settings thoroughly yet.
 
Last edited:
Webmastertools and analytics are tightly knit at google. And to use webmaster tools your site has to be verified.

The recommended from google is asynchronous snippet in your head tag
I see, thanks. I verified for Webmaster Tools with an HTML file, I don't think verifying with Analytics was always an option. Strange that it's more finicky about it being in the <head> than Analytics itself is.

What string did you guys add to blacklist Google Analytics? ga.js?
You can literally put any part between the <script> tags and it should pick it up. I'd recommend "google-analytics" because it will work with both the old ga.js and the new universal analytics.js
 
I will give that a shot.

I am wondering if it is a good idea to hardcode the google tracking code blacklist into your mod Jeremy since the google property code insert is built into xenforo code.

It may prevent others, such as myself, from finding out the hard way that the code must be blacklisted, or not finding out at all.

Just a thought.
 
Google Analytics works fine without blacklisting, it's just Webmaster Tools verification which doesn't seem to look for it beyond the <head> tags. Probably similar to why XenForo won't find <title> tags for auto-linking if they're too far down the page, just a limitation of the page-scraping mechanism they use.

I've gone ahead and edited the add-on page to make it clearer that a blacklist is available though, and put an item in the FAQ about Webmaster Tools verification.
 
  • Like
Reactions: CTS
Sounds good.

Fwiw, for webmaster tools verification and analytics, all I did prior to installing your mod was insert my property number built into the google tools built into xf1.5.

So it works for webmastertools and analytics concurrently.
 
Hello, for some reason "Defer JS" breaks my downloads of big attachments. We host audio interviews so the files be near 100mb sometimes.
 
Last edited:
Hello, for some reason "Defer JS" breaks my downloads of big attachments. We host audio interviews so the files be near 100mb sometimes.

"ErrorException: Fatal Error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 95454275 bytes) - library/Jrahmy/DeferJs/Listener.php:30"

Is there a way to get around this?
Yeah, I will release a fix for that shortly. The add-on does disable itself for attachments, but only after it has checked the output for HTML. I will reverse the order there.

Also, it breaks this javascript for my banners but when I try to put in a unique string it still does not work. Any ideas?
A unique string on its own line should have worked. Something like 'adBanner1'. If your script has other dependencies they would need to be blacklisted too, but it appears to be standalone.
 
Please can you add option Remove query strings from static resources?
The query strings are used for cache busting in XenForo. If you remove them (and have far-future expires headers for your static resources, which you absolutely should), then your users will not be able to receive proper updates to these resources.

The only real problem query strings pose is some proxies will not cache them, which is not applicable to most people. So if you're just chasing a few PageSpeed points, it's not really a worthwhile effort.
 
to make it running with 5.3 ENV :

in line 92

Code:
            ['<!--', '-->'],
            [' /* <![CDATA[ */ ', ' /* ]]> */ '],
            $matches[0]

Replace by

Code:
array ('<!--', '-->'),
           array (' /* <!(CDATA( */ ', ' /* ))> */ '),
 
It should function. Not sure why it's saying that on your site though. I can confirm that it's working fine in my forums (with PHP 5.6.12).
 
Does this still function? Installed and Google PageSpeed and my own inspection shows JS still loading closer to first.
Still working for me. If you link me to your site, I can double check whether or not it's working. If it's not working, that'd be down to add-on conflicts or other strange issues though.
 
Top Bottom