node.jsgulpbrowser-syncbandwidth-throttling

How do I Throttle BrowserSync's speed?


How can I configure BrowserSync (from its API) to serve up content at a slower rate?

Ideally I'd like to be able to serve only certain files at the throttled rate, so when developing, localhost/index.html loads fast and localhost/dummyData.json loads slowly, so I can effectively demo loading states while developing web apps that decouple data and presentation.


Solution

    1. start browser-sync: browser-sync start --server --files "src/*.*"
    2. open the browser-sync UI (e.g. http://localhost:3001/) and go to "Network Throttle" enter image description here
    3. select "Speed", then "Create Server"
    4. Use the new server instance which is now running at the defined speed

    HINT:

    You can run multiple throttled server instances an the same time - eg. to simulate CDN behavior (where the fastest wins)

    You can also simulate latency! Have a look at the bs-latency Plugin ...