• Hello
    I am relatively new in WordPress, Javascript and CSS. I just want to have some interactive features. For example, using 2016 theme, I want to know where I can place CSS or Javascript files when I want to implement some interactive features. Text Editor in WordPress only allows HTML.
    Thanks,
    Myo

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator t-p

    (@t-p)

    Moderator bcworkz

    (@bcworkz)

    Meh, I don’t care much for t-p’s link 😛 It’s totally correct as far as it goes, but doesn’t warn you about the risks of editing theme files or how to properly get external files loaded. For little snippets here and there, it’s probably fine. For more serious efforts it falls short. IMHO of course.

    If you add your JS and CSS to your twentysixteen files, your changes will likely be lost when the theme is updated. To protect your changes, you should create a child theme. Another alternative is to create a basic, simple plugin. Plugins are not quite as good as child themes for custom CSS because it’s more difficult to ensure your CSS is loaded after the theme’s unless you are targeting only one specific theme.

    To ensure CSS and JS external files are loaded in the correct order, you should load them with wp_enqueue_script() and wp_enqueue_style(). These functions give you the ability to specify dependencies. WP will then be sure dependencies are loaded first.

    Thread Starter mthant

    (@mthant)

    I am just thinking of creating some simple interaction like simple calculator. Can that be affected by WordPress updates?

    Moderator bcworkz

    (@bcworkz)

    It depends on where you put your code. If it resides on files that are subject to updates, then your code can be overwritten. If you alter core WP files (never do this!) then WP core updates can overwrite your work. It’s not a guarantee, not all files are updated each time. Sooner or later though…

    If you alter or add to theme files and the theme is updated, then you could lose your work. If you alter or add to plugin files, when the plugin is updated, you could lose your work. Some themes have designated files that are meant for user customizations, such files when available should be safe.

    To ensure your custom work is safe from updates, either create a child theme or your own plugin. Either one is easy to do. It can then be the repository for all your custom work.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Using Javascript, CSS in WordPress’ is closed to new replies.