Every page of every website needs assets such as styles, scripts and even specific back-end code. The idea is to load all that stuff on a page-by-page basis (dynamically). Once a page detects that it needs a certain thing it just loads it. Selective assets loading. Magic.
It allows for having virtually unlimited libraries of optional components and customisation. A web-dev paradise.
Each page of a website have different size and complexity. Yet in a typical frameworks such as WordPress, every single page, even the simplest one, needs to load all of the code and assets for all plugins you might have activated on your website such as registration forms, sliders, photo-galleries, re-captcha and what not – everything. Often to simply say Page not found.
This is okay with very small sites but becomes problematic as a website grows.
In WordPress, dynamic asset loading can be achieved by early post access. In other words we can retrieve the post ID before the
wp hook. We scan the post content and the metadata before enqueuing assets. It allows each page to be thoroughly customised with additional components and overrides.
Separate admin and front end
Admin panel and front-end of the website need different assets. E. g. in WordPress there is a simple template tag
is_admin() that can be used to determine whether an asset is needed or not. It’s actually slightly more complex but just to give an idea.
There are very few things that are required on every single page. That includes but is not limited to SEO optimisation, cache management, redirections, analytics and… that’s pretty much it.