-
Notifications
You must be signed in to change notification settings - Fork 63
Implement block specific scripts similar to stylesheets #506
Comments
Hi @cameronjonesweb, |
This could be a really useful idea, enqueuing JS for blocks. My only concern might be performance. I should do another PHP profiling test to see the cost of this. So far, it looks like the performance cost of BL enqueuing block stylesheets is high, compared to the overall performance cost of BL. For example, the CPU time of Block_Lab\Util::locate_template() in this profile is 7.6 ms and the clock (real) time is 19.3 ms, compared to an overall performance cost of BL of about 87 ms. Still, more testing is needed before writing off this idea. I think enqueuing JS could be really useful. |
Hi @cameronjonesweb, In the meantime, in case you didn't notice it, there's an action where you could enqueue scripts for a block: block-lab/php/blocks/class-loader.php Line 404 in 32e71bb
Of course, that's not as useful as Block Lab doing the enqueuing automatically 😄 Have a great rest of the weekend. |
Feature description
As defined in #249, styles can be automatically included when the block is active on a page. I think it would be nice if block scripts could be included on the front end in a similar manner.
Screenshot (optional)
Use case
There are plenty of types of block that could utilise front end only scripts. An accordion panel for example, or tabbed content.
Additional information
Just think this could be a good feature, considering styles are already loaded this way.
The text was updated successfully, but these errors were encountered: