[wp-trac] [WordPress Trac] #50328: Enqueue script and style assets only for blocks present on the page
WordPress Trac
noreply at wordpress.org
Wed Jul 1 17:47:32 UTC 2020
#50328: Enqueue script and style assets only for blocks present on the page
-------------------------+-------------------------
Reporter: aduth | Owner: gziolo
Type: enhancement | Status: assigned
Priority: normal | Milestone: 5.5
Component: Editor | Version:
Severity: normal | Resolution:
Keywords: | Focuses: javascript
-------------------------+-------------------------
Comment (by gziolo):
@westonruter, I'm trying to print those styles and scripts on the front-
end using the approach found in the plugin you shared:
https://github.com/westonruter/syntax-highlighting-code-
block/blob/e652901420ee6991213eba11e7c8c52176e84e0c/syntax-highlighting-
code-block.php#L346-L352
It works for the front-end perfectly fine, but I run into an issue in the
editor. If the block isn't inserted into a post, everything works
correctly. As soon as insert it into the post, it renders JS and CSS
inside the preloaded REST API call for the post object :)
So I have two questions:
1. Is the approach I took valid, or did I misunderstood what you were
proposing?
2. If (1) is on track, any thoughts on how I can prevent rendering CSS/JS
inside the preloaded REST API call :)
--
Ticket URL: <https://core.trac.wordpress.org/ticket/50328#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list