Close

Copyright © RebelMouse 2019

Follow Us:

Playing Around with Bootstrap Object

Bootstrap is an object with all the necessary data for displaying a certain page. It's data is outputted in console on every load:


You might need something from this object, but the problem is that Bootstrap is not globally available:

We also couldn't know at which point of time is it loaded so we could require it:

bootstrap = require('bootstrap');


Dispatching Bootstrap

It is quite easy to implement event dispatcher which we can listen and it will tell us when Bootstrap is loaded. First you need to find where in the files the load happens:

grep -Rin "console.log('bootstrap', Bootstrap);" engine/

Example:

In those files you need to dispatch the actual event so you can listen later. Steps:

  1. Add event dispatcher (core/event_dispatcher) to the list of dependencies.
  2. Add event dispatcher (eventDispatcher) to the definition function as function argument on the same position as you add it to dependencies.
  3. Dispatch the bootstrap loaded event:
  4. eventDispatcher.trigger('boostrap:loaded', Bootstrap);

Here is an example of all three changes:


Listening Bootstrap

When you have done upper steps, you can listen to it on any page you want with this code:

<script type="text/lazy-javascript" priority="1">    require(['core/event_dispatcher'], function(eventDispatcher) {        eventDispatcher.on('boostrap:loaded', function(Bootstrap) {            console.log(Bootstrap);        });    });</script>

RebelMouse CEO: Reimagining Diversity “Starts in the Office”

Why women, minorities, and the LGBTQ+ community will restructure workplace norms

Entering a new decade means a new opportunity to change how we approach diversity. In a joint interview alongside Leanne Pittsford of Lesbians Who Tech, RebelMouse founder and CEO Andrea Breanna said that the only way to fight patriarchal dominance is to encourage and nurture more women, minorities, and members of the LGBTQ+ community in the workplace, particularly in tech.

Over half of RebelMouse's employees are women or identify as LGBTQ. Read our full diversity and inclusion report here.

Check out the full video below.

Related Articles

Publishers No Longer Have to Submit Their Site to Google News

Google's Publisher Center creates new opportunities for audience growth

Just before the start of the next decade, Google announced an important change to its Google News offering with the launch of Google Publisher Center. The new interface merges Google News Producer and Google News Publisher into one to streamline the partnership process for publishers.

Overall, the change should make it easier for publishers to manage their Google News settings, including updating themes, directing URLs to section pages, and configuring user permissions. Read the full list of features here.

Keep reading...

How to Find Work-Life Balance as a Remote Employee

Tips from our CEO on making the most of an office-free lifestyle

Working from home is becoming increasingly popular, with an estimated 66% of companies now allowing remote work and 16% operating completely office-free. RebelMouse is one of those fully remote companies, and over the years we've mastered how to stay close to each other despite being spread across more than a dozen countries. We believe working remotely is good for both our personal lives and our productivity. Read more about this here.

Still, working free from the shackles of an office environment doesn't mean every day is a dance party in your pajamas from 9 to 5. Working from home comes with its own set of challenges just like any other job.

Keep reading...
Subscribe to Our Newsletter