O'Reilly logo

Drupal 8 Development Beginner's Guide - Second Edition by Kurt Madel, Malabya Tewari, Rakesh James, Krishna Kanth, Edward Crompton, Samuel Keen, Tassos Koutlas, Neeraj Kumar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action – calling assets on specific pages

Let's dive a little deeper with asset library dependencies. We're going to add a little piece of JavaScript with a dependency on jQuery; when a user clicks on the recipe description field, an alert box will be triggered to tell them it's delicious. We'll set it so that it only loads on the full view mode of our recipes (that is, not on our homepage listing). This will also be our first introduction to Twig. Let's begin:

  1. Back in PhpStorm, in our recipes theme, create a directory called js.
  2. In the js directory, create a file called delicious.js.
  3. While the contents of this JS file are just to demo the concept, we'll create it and document it using good practices, so that you can use this as a basis ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required