On the Modifications tab, I have had some very good luck with the Experimental Settings/"Move Google Analytics analytics.js code from inline to be a file". I use the Google Analytics and Commerce Google Analytics modules and my data capture has been perfect, and PageSpeed Insights is no longer yelling at me to Leverage Browser Caching.
So then I added the Facebook Pixel module as well. Much like the problem I had before with my Analytics tracking code, PageSpeed Insights is once again telling me:
Leverage Browser Caching for the following resources:
https://connect.facebook.net/en_US/fbevents.js (20 minutes)
https://connect.facebook.net/…signals/config/1961054097462651?v=2.7.16 (20 minutes)
So.......
Question 1) Why is the modification "Move Google Analytics analytics.js code from inline to be a file" still considered an "Experimental Setting"? I've been using it for nearly a year through several version releases of Advagg and it's worked smoothly. Are there people out there who are having trouble with it still or some other issue?
Question 2) How hard would it be to implement a similar functionality for Facebook Pixel tracking codes? I feel like the two tracking codes function in a similar way. Could this be implemented for the Facebook Pixel tracking codes?
Question 3) On a broader scale, there are probably other tracking codes besides these two that get used on various sites. Rather than a script-specific implementation, how hard would it be to make a general option to select which scripts to move from inline to be files?
I'm not a developer and I only have some very basic programming skills, so I don't know what the scope of something like this would be. Still, if the maintainer decides to work on this and there is something I can do to help, just ask. :)
Comment | File | Size | Author |
---|---|---|---|
#18 | advagg-2886940-18-remote-css-js-to-local.patch | 58.09 KB | mikeytown2 |
| |||
#17 | advagg-2886940-17-remote-css-js-to-local.patch | 52.08 KB | mikeytown2 |
| |||
#16 | advagg-2886940-16-pull-external-css-js-local.patch | 46.59 KB | mikeytown2 |
| |||
#15 | advagg-2886940-15-pull-external-css-js-local.patch | 22.81 KB | mikeytown2 |
| |||
#14 | advagg-2886940-14-pull-external-css-js-local.patch | 21.42 KB | mikeytown2 |
|
Comments
Comment #2
mikeytown2 CreditAttribution: mikeytown2 commentedI might want to move it out into the relocation sub module. It's already inlineing google fonts, doing the same for JS makes sense. FB has a really short TTL (20 min) so it's a little bit harder to do in comparison to GA but should be possible.
Comment #3
mikeytown2 CreditAttribution: mikeytown2 commentedExample for me
https://www.googletagmanager.com/gtm.js?id=GTM-56CK7R (15 minutes)
https://connect.facebook.net/en_US/fbevents.js (20 minutes)
https://connect.facebook.net/signals/config/1540626602827177?v=2.7.16 (20 minutes)
https://www.google-analytics.com/plugins/ua/linkid.js (60 minutes)
https://www.google-analytics.com/analytics.js?org68b (2 hours)
Going too see what I can do...
Comment #4
mikeytown2 CreditAttribution: mikeytown2 commentedInline GA code without script loader
(function(i,s,o,r){i["GoogleAnalyticsObject"]=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date()})(window,document,"script","ga");ga("create", "UA-XXXXXXX-X", {"cookieDomain":"auto"});ga("set", "anonymizeIp", true);ga("send", "pageview");
Comment #5
mikeytown2 CreditAttribution: mikeytown2 commentedNo UI, no control, proof on concept code.
Comment #7
mikeytown2 CreditAttribution: mikeytown2 commentedComment #9
mikeytown2 CreditAttribution: mikeytown2 commentedComment #11
mikeytown2 CreditAttribution: mikeytown2 commentedComment #13
mikeytown2 CreditAttribution: mikeytown2 commentedComment #14
mikeytown2 CreditAttribution: mikeytown2 commentedStill need to handle @import statements for external CSS files, better code doc, put in a UI, and merge duplicate functionality. Looking good though.
@import needs to use
with a different _advagg_load_stylesheet() function.
Comment #15
mikeytown2 CreditAttribution: mikeytown2 commentedGot this working with import now. Still need code doc, move code to .inc, UI for control, and merge duplicate functionality. Also need to keep #2889776: Remove no longer needed dns-prefetch and preconnect link tags in mind. Should also check if fonts loaded via deep import statements are handled. Need to try drupal_http_request again on failure.
Appears that there is a bug with nested import statements... might be core related.
Quick testing code
Comment #16
mikeytown2 CreditAttribution: mikeytown2 commentedFunctionally it's there. UI is there, but not really plugged in the code; need to add in the states array as well. Look into merging duplicate code functionality.
Comment #17
mikeytown2 CreditAttribution: mikeytown2 commentedUI needs states array; need to pass variables into the $aggregate_settings array.
Comment #18
mikeytown2 CreditAttribution: mikeytown2 commentedShould be good to go.
Comment #20
mikeytown2 CreditAttribution: mikeytown2 commentedComment #22
TynanFox CreditAttribution: TynanFox as a volunteer commentedDude, MikeyTown, you're a machine. :)
Thanks for this!
Comment #23
mikeytown2 CreditAttribution: mikeytown2 commentedYou're welcome! Let me know how it works for you. The Facebook pixel code was quite difficult to pull off, but I have it working on our site; getting a 100/100 on google page speed when using google analytics & tag manager as well as FB pixel https://developers.google.com/speed/pagespeed/insights/?utm_source=analy...