#!/usr/bin/env python # coding: utf-8 # # Using external javascript libraries # If you need to use some 3rd party lib you can use folowing technique. # Define map of js paths. You can use for example path of libraries provided [here](https://cdnjs.com/libraries). Remove `.js` from path it will be added automaticaly. # In[ ]: get_ipython().run_cell_magic('javascript', '', "require.config({\n paths: {\n 'big': '//cdnjs.cloudflare.com/ajax/libs/big.js/5.2.2/big' \n }\n});\n") # In[ ]: get_ipython().run_cell_magic('javascript', '', "require(['big'], function(Big) {\n window.Big = Big;\n});\n") # In[ ]: get_ipython().run_cell_magic('javascript', '', 'var a = 0.3;\nvar b = 0.1;\nvar c = new Big(a);\n\nbeakerx.displayHTML(this, `\nusing floats: ${a-b}
\nusing big.js: ${c.minus(b)}\n`);\n')