craftcms / docs

Documentation for Craft CMS, Craft Commerce, and other official products.
https://craftcms.com/docs
38 stars 145 forks source link

Improve “Tags” #477

Closed tsawitzki closed 1 year ago

tsawitzki commented 1 year ago

I have a suggestion for https://craftcms.com/docs/4.x/dev/tags.html

For the {% js %} please provide more in-depth information on how it works regarding duplicate requests, since on Stackexchange it says: "includeJsFile handles duplicate requests for you, so it doesn't matter if there's more than one someBlockType block – the actual external JS resource will only be requested once." (https://craftcms.stackexchange.com/questions/15663/loading-javascript-on-specific-sections-pages) If this is true, this would be a very important information.

AugustMiller commented 1 year ago

I have added some context to the {% js %} tag documentation: https://craftcms.com/docs/4.x/dev/tags.html#js

The technical side of duplicate detection can be summarized like this:

Blocks are registered with a key derived from the md5 hash of its contents, after stripping whitespace from its start and end, and ensuring it is terminated by a semicolon.

Some examples follow this, in the docs!

(See the Yii source that defines this behavior, here.)

Let me know if you have any other questions. 💞