Coder Social home page Coder Social logo

Comments (6)

zserge avatar zserge commented on May 10, 2024 2

Embedding itself is possible with go-bindata, xxd -i (for C/C++) etc. It's not a big problem.
How to use embedded resources?

  1. Use blank URL when creating your webview. It will make bare minimal HTML ready for script injection.
  2. Use w.Eval(js) (Go) or webview_eval(w, js) (C/C++) to inject JS libraries - BabelJS, frameworks, your app code.
  3. Use w.InjectCSS(css) (Go) or webview_inject_css(w, css) (C/C++) to inject CSS stylesheets.

For images and webfonts you have to embed them into JS first (base64-encoded). Webpack can do that.

And I think that's it.

file:// is an option, but last time I tried it - it worked really strange on Windows.

from webview.

1l0 avatar 1l0 commented on May 10, 2024 1

An example here.

from webview.

1l0 avatar 1l0 commented on May 10, 2024

See an example that uses go-bindata as a tool for embedding binary data into a code.

from webview.

akamensky avatar akamensky commented on May 10, 2024

@1l0 That's good, but does it work for images for example and specifically in a context of this library?

from webview.

Boscop avatar Boscop commented on May 10, 2024

Afaik, if you don't want to serve the images through a file:// url or from a local web server, the only way is to base64 encode them as data urls.

from webview.

aftabnaveed avatar aftabnaveed commented on May 10, 2024

@zserge webview_inject_css does not seem to exist in webview.h file. Was it deprecated?

from webview.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.