HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
"assetModel_styleCss_handler" for JS
Shadowdare
MVP
We can use the assetModel_styleCss_handler
to include a "CSS file in all non-Dashboard pages" (not admin back-end pages).
Is there a similar one for including JS files? If not, what's a good way to only include JS files on the front-end?
One way I like is if ($sender->MasterView !== 'admin')
.
Add Pages to Vanilla with the Basic Pages app
0
Comments
Can't you simply base render ?
$sender->addJsFile(asset('cache/pluginname/'.c('pluginname.configname').'.js', true));
❌ ✊ ♥. ¸. ••. ¸♥¸. ••. ¸♥ ✊ ❌
The
base_render_before
event code is run in the admin dashboard too. This is where putting the addJsFile() or addCssFile() calls within aif ($sender->MasterView !== 'admin')
block would do the trick. I forgot to clarify where I'd use this in the first post.I'm looking for an event like
assetModel_styleCss
, which adds CSS only to non-admin pages, for JS.Add Pages to Vanilla with the Basic Pages app
❌ ✊ ♥. ¸. ••. ¸♥¸. ••. ¸♥ ✊ ❌
You can add js files like that:
but using base_render_before is much more common.
I have opened an issue about a JS-event similar to
styleCSS
before:https://github.com/vanilla/vanilla/issues/3020
I believe this is going to be unified at some point when asset minification is going to arrive in the core.
My themes: pure | minusbaseline - My plugins: CSSedit | HTMLedit | InfiniteScroll | BirthdayModule | [all] - PM me about customizations
VanillaSkins.com - Plugins, Themes and Graphics for Vanillaforums OS
@R_J, although JS files can be added in
assetModel_styleCss
, the documentation only shows it being used for CSS, so another event may be added for JS files. @Bleistivt, I believe it probably is going to be used for asset minification, too.I recall that a experimental config setting was added in Vanilla to enable asset minification, but haven't seen any updates about the feature.
Add Pages to Vanilla with the Basic Pages app
I know minification is on the roadmap for ops, but I don't know the details of how it will be implemented or the specific constraints surrounding it.