Code Monkey home page Code Monkey logo

Comments (3)

futtta avatar futtta commented on May 25, 2024

no, there is not (yet).

from autoptimize.

pbowyer avatar pbowyer commented on May 25, 2024

Thanks for your work on Autoptimize. I switched to it last month; previously I was using BWP-Minify, which had highly variable load times and broke Google's "This Site is Mobile Friendly" check.

Due to legacy code the site I'm working on needs some JavaScript in the <head>, so I used WordPress's wp_enqueue_script to assign some scripts to the head and the majority to the footer. BWP Minify compressed these where they were, and I ended up with two minified JS files.

I understand why Autoptimize scans the HTML vs hooks into the WordPress functions. I thought property $domovelast would let me specify which files to put in <body> when "Force JavaScript in <head>?" is checked, but that's not its purpose.

Are you open to a patch that would add this functionality? I envisage another setting called "Preserve head/body location of JavaScript", and then changing the parsing and extraction to treat the <head> and <body> separately, and then merge back together or not depending on the setting.

If there's a better way to handle this, or it is already present, it'd be great to hear.

from autoptimize.

futtta avatar futtta commented on May 25, 2024

Welcome @pbowyer :-)

Best way to do this without having to code would be not to force JS in head, but to exclude the JS you want to stay in head (which I assume/ hope is a short list). you could then use the new autoptimize_filter_js_minify_excluded filter in the upcoming AO2.2 to minify the JS in head?

But if you were to code and you would do a PR, I would most certainly consider off course :-)

from autoptimize.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.