Drupal Noob here, so this may be a silly question....

I'm trying to take an existing clients none-drupal website, using just the html source code and assets, and bring it in to the twig file to insert 3rd party content while keeping the sites original look. The issue is; the clients websites will typically contain multiple js/css calls within the source as well as in-line js, and sometimes inline css. The site I am currently messing with has ~64 assets calls.

All of these things need to stay within the same area of the source code, typically, in order for the page to render properly. For example; jQuery needs to be called before a js file that uses jQuery.

How would we go about doing this using YML, or is this not possible and we would need to hardcode it into the twig files? I know hardcoding works but obviously it's not the best solution.

Thanks!

Comments

Jeff Burnz’s picture

Study the libraries asset system for Drupal 8, its very well documented.

Load order of dependancies is automagical in Drupal 8. If you add jQuery as a dependancy it will load before the script.

https://www.drupal.org/docs/8/theming-drupal-8/adding-stylesheets-css-an...

Using inline assets is not recommended at all in D8, however you can either hard code it into templates, or if you want it in the head use something like $variables['#attached']['html_head'] in a preprocess function. However reams of inline JS tells me something is extremely hackish about the current site, so maybe a time to rectify that situation.