[wp-trac] [WordPress Trac] #48098: ReferenceError: jQuery is not defined even if it is enqueued ('wp_display_script_once' needed) (was: ReferenceError: jQuery is not defined even if it is enqueued)

WordPress Trac noreply at wordpress.org
Wed Sep 25 09:17:27 UTC 2019

#48098: ReferenceError: jQuery is not defined even if it is enqueued
('wp_display_script_once' needed)
 Reporter:  KestutisIT               |       Owner:  (none)
     Type:  defect (bug)             |      Status:  reopened
 Priority:  normal                   |   Milestone:
Component:  Script Loader            |     Version:  5.2.3
 Severity:  normal                   |  Resolution:
 Keywords:  2nd-opinion needs-patch  |     Focuses:  javascript
Changes (by KestutisIT):

 * keywords:   => 2nd-opinion needs-patch
 * status:  closed => reopened
 * resolution:  wontfix =>


 Replying to [comment:3 peterwilsoncc]:
 > Thanks for providing additional information.
 > As noted above, the purpose of the `wp_enqueue_scripts()` function is to
 output a script tag in either the header or footer of an HTML document.
 There are other functions to print script tags immediately.
 What functions exactly?

 As I'm lead architect in out team, our whole DEVELOPERS DEPARTMENT was NOT
 ABLE to figure out what the hell is happening here for a half day, I can
 confirm - that this is UNEXPECTED BEHAVIOR.
 And if we want to have new developers from other systems comming to
 WordPress, especially those, that are familiar with MVC-like architecture
 with full template separation, they will never get the point what is
 happening here.
 If template we MUST NEVER HAVE function() {...} like function, or we are
 breaking THE BASICS OF CLEAN CODE - we are messing Code and template. And
 the JavaScript should not ever be hidden somewhere in model or controller,
 because we have to allow designers fully change the UI and UX
 (interactions, spinners etc., that are handled by jQuery hooks).

 So I'm reopening this ticket, and adding an additional proposal here:
 1. Please follow the PHP logic, that already has 'require_once' and
 'include_once' functions,
 so suggest to add '**wp_display_script_once()**' new WordPress function
 via this tickets (please update it's content, as I cannot do that), if you
 cannot update existing functions.

 Once again, believe me, I'm not the only one. We been this weekend on
 biggest hackathon of the Port of Klaipeda, with hundreds of developers
 HERE**, so instead we BROKE WHAT WORDPRESS says and used **<script>**
 directly in the template, and WordPress says we should never do this (due
 to support for Amazon S3 script loading, or to avoid double-loading).

Ticket URL: <https://core.trac.wordpress.org/ticket/48098#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform

More information about the wp-trac mailing list