Repository navigation
Only load block assets on frontend when block exists. - #226
jamesmorrison wants to merge 14 commits into
Conversation
dkotter
left a comment
There was a problem hiding this comment.
Couple typos that were preventing this from working properly on the front-end.
Once addressed, this does work and may be good enough. I am curious though, looking at the original issue, why this ends up loading the block editor script at all on the front-end? Seems like there may be a bigger issue here with how this block is built/registered that may be worth changing to fix the problem here
Co-authored-by: Darin Kotter <darin.kotter@gmail.com>
Co-authored-by: Darin Kotter <darin.kotter@gmail.com>
@fabiankaegy any insights from your perspective on this? |
Yeah ideally we should enqueue the assets via the |
…rontend script loading.
|
@jeffpaul / @dkotter / @fabiankaegy Sorry it's taken so long for me to make the requested changes here. I've refactored this to use the viewScript; tested and working locally. I chose to leave the frontend.js file in case it's needed, let me know if you'd like this removed. Please could you review the updates here? |
peterwilsoncc
left a comment
There was a problem hiding this comment.
This looks good to me and is testing well. I've confirmed the tabs components' assets are enqueued only when the block is included in the mark up.
I've answered your question about frontend.js inline.
Note: for testing purposes I merged in the develop branch but I haven't pushed in case you have a preference for rebasing.
…Cypress tests" This reverts commit 2a40ab4.
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

Description of the Change
Adds conditional check that the block (Tabs / Tab Items) exist on the post before enqueueing assets.
Closes #199
How to test the Change
/dist/blocks/tabs-item-block.jsand/dist/blocks/tabs-block.cssare not enqueuedChangelog Entry
Credits
Props @jamesmorrison
Checklist: