PHPackages                             brain/occipital - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. brain/occipital

AbandonedLibrary[Utility &amp; Helpers](/categories/utility)

brain/occipital
===============

Occipital is a package for asset management in WordPress.

0.1.0(10y ago)143631GPL-2.0+PHPPHP &gt;=5.4

Since Feb 23Pushed 10y ago2 watchersCompare

[ Source](https://github.com/gmazzap/Occipital)[ Packagist](https://packagist.org/packages/brain/occipital)[ Docs](https://github.com/Giuseppe-Mazzapica/Occipital)[ RSS](/packages/brain-occipital/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (1)Dependencies (5)Versions (2)Used By (1)

Occipital
=========

[](#occipital)

[![Occipital](https://camo.githubusercontent.com/3149dc13fe6ccd6cbb04441b9b0fc7a89f87c9904e80902877f20929574a2086/68747470733a2f2f676f6f676c6564726976652e636f6d2f686f73742f3042786f3462486257456b4d73636d4a4e596b78365958637461574d2f6f636369706974616c2e706e67)](https://camo.githubusercontent.com/3149dc13fe6ccd6cbb04441b9b0fc7a89f87c9904e80902877f20929574a2086/68747470733a2f2f676f6f676c6564726976652e636f6d2f686f73742f3042786f3462486257456b4d73636d4a4e596b78365958637461574d2f6f636369706974616c2e706e67)

[![Build Status](https://camo.githubusercontent.com/b41e43e302e5fb704b5fa5b2c492cb49fcb8cac70d81caec3498032b6e26b99a/68747470733a2f2f7472617669732d63692e6f72672f47697573657070652d4d617a7a61706963612f4f636369706974616c2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/Giuseppe-Mazzapica/Occipital)

Occipital is a [**Brain**](http://giuseppe-mazzapica.github.io/Brain/) module for **style and scripts management**.

It allows a better way to enqueue scripts and styles in WordPress.

Occipital, like others Brain modules is **not** a full-plugin, its a package to be embedded in larger projects.

However, embed in a theme or in a plugin is just matter of, literally, 3 lines of code and there is a [step-by-step guide](/occipital-in-theme-guide.md) to include Occipital in a theme.

---

\##What's wrong with standard styles and scripts handling in WordPress?

Have a look to related [**blog post**](http://gm.zoomlab.it/2014/whats-wrong-with-styles-and-scripts-in-wordpress/).

---

\#Features

- Possibility to define, for each asset, which other assets it **provides**, so that WordPress can skip loading them decreasing number of HTTP requests per page.
- Easy to use API that allows to add assets and additional data in one single place, with no need to use 3 different functions like `wp_register_script`, `wp_enqueue_script` and `wp_localize_script` (or `wp_add_inline_style` for styles).
- Conditional callback with rich context: for every asset is possible to set a "condition" as a callback: the asset is printed to page only if the callback returns true. That callback receives as argument current main [`WP_Query`](https://developer.wordpress.org/reference/classes/wp_query/) object in frontend and current [`WP_Screen`](https://developer.wordpress.org/reference/classes/wp_screen/) on backend, alongside current logged user (if any).
- Rich API to get and modify assets properties (url, dependencies, provided assets, version...) *on the fly*
- Custom hooks fired before and after an asset is printed to markup, for a great flexibility.
- Correct handling of styles in `` for login / register page.
- Just like all Brain packages, it is coded using all modern OOP PHP code and fully unit-tested.

---

\#Quick Start

All the things in Occipital can be done via API class: **`Brain\Assets`**.

Before do any call, you should wait for `'brain_loaded'` hook, or `'init'` if you prefer core hooks.

Below an example with all the methods available for scripts (only 2 are required):

```
