Adding conditional CSS and JavaScript

Video loading...

Join Drupalize.Me to watch this video

Join today and gain instant access to our entire video library.

Log in Sign up
  • 0:02
    Adding Conditional CSS and JavaScript
  • 0:06
    with Michelle Lauer
  • 0:08
    In this chapter, we are going to discuss adding
  • 0:10
    conditional CSS or JavaScript.
  • 0:14
    There's going to be some scenarios where you're going to want
  • 0:16
    a unique file, either JavaScript or CSS, to only
  • 0:21
    be called on certain pages, and we're going
  • 0:23
    to walk you through that process.
  • 0:25
    So my designer has come to me and said
  • 0:27
    we want the background of the front page only to be pink,

Adding Conditional CSS and Javascript

Loading...

In this video we will look at how to add CSS and JavaScript to our site using drupal_add_css() and drupal_add_js(). We will also show using these functions to conditionally add the CSS and JavaScript, within our page preprocess function.

Additional resources: