[wp-trac] [WordPress Trac] #38242: Support media queries in wp_enqueue_script() akin to wp_enqueue_style() to prevent loading scripts unnecessary
WordPress Trac
noreply at wordpress.org
Fri Oct 7 01:02:08 UTC 2016
#38242: Support media queries in wp_enqueue_script() akin to wp_enqueue_style() to
prevent loading scripts unnecessary
---------------------------+----------------------
Reporter: BjornW | Owner:
Type: enhancement | Status: closed
Priority: normal | Milestone:
Component: Script Loader | Version: trunk
Severity: normal | Resolution: wontfix
Keywords: close | Focuses:
---------------------------+----------------------
Changes (by dd32):
* status: new => closed
* resolution: => wontfix
* milestone: Awaiting Review =>
Comment:
As I said in #core @
https://wordpress.slack.com/archives/core/p1475752552004667 I don't think
this is really going to be viable for core inclusion.
Conditionally loading JS based on media queries seems like something
that's either best done by a helper script (even using
`wp_add_inline_script()`), or as a feature detection within the script
itself on whether or not to spend time executing certain procedures.
One big question in my mind, is what happens when the window resizes? or
rotates as in mobile devices, are those scripts then loaded at that point
in time? What happens to existing ones which matched the query, but no
longer do?
So although I like the suggestion, as long as browsers don't natively
support it, I think it's best left up to the JS itself to handle
conditional loading.
I'm going to mark this as `wontfix` for the reasons above, even though I
like it, hopefully one day either this sort of thing won't be needed, or
browsers support it natively.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/38242#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list