• Resolved Bethzy Elonia

    (@east2611)


    Hi I am using “w3 total” minify javascript setting, so it combines and generates a single javascript file in head https://skcamera.com/wp-content/cache/minify/10bf8.default.include.9c70f4.js and I also use cloudflare “rocket loader functionality” but I want cloudflare rocket loader to ignore this head specific script. For this cloudflare recommends to add data-cfasync="false" before the ‘src’ attribute of javascript. reference article here
    But I don’t know how to add this attribute bcoz the javascript is plugin generated and I can not find it in my templates.
    Is there some code that I can add to my function.php file to automatically add this attribute to javascript file before other javascript file loads.

    • This topic was modified 5 years, 10 months ago by Bethzy Elonia.

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello,

    Are you using JS minify in both Cloudflare and W3 Total Cache?

    Thread Starter Bethzy Elonia

    (@east2611)

    For HTML and javascript minification I am just using w3 total cache and for css minification I am using Cloudflare. The cloudflare rocket loader defers the javascripts but I don’t want that specific javascript to be defered by cloudflare.

    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello,

    You can use ob_start(custom_callback); and in the callback add the attribute using preg_replace or something like that.
    Please understand that this is a specific use case and you should test the suggestion above.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Add data-cfasync=”false” attribute to the minify javascript generated by W3Total’ is closed to new replies.