logo elektroda
logo elektroda
X
logo elektroda

How I reduced my IoT config page size 11 times by using Javascript instead of static HTML

p.kaczmarek2 2766 30
ADVERTISEMENT
  • #31 21249224
    max4elektroda
    Level 20  
    max4elektroda wrote:
    So my idea is to put this all together in one place - maybe an array of a struct containing all information in one place.
    That will be quite some work to implement and change all functions using this.
    But it would mean there is only one place to maintain.


    It really took a very long time to finally find an approach to maintain the actual (good) approach to store a pins role as char, using "enum ioRole_e" to define them.
    So you always have to define a "parallel" implementation (regarding the index) e.g. to hold the names used in HTML code.

    I finally found a way to generate the enum from a file containing the other information/properties, too.

    So in PR#1378 is a first implementation:

    The enum is not directly present as code, but generated by a macro
    All information present is generated from the original sources, so it should be consistent.

    My "test" was to compare the resulting web-page (var r = ...).
    This var is generated by use of "enum", the HTML-name and th number of channels and is equal (exept the one fix I made that "BL0937SEL_n" also needs "0" channels (it was defined for 1 before).

    So, I'm quite sure the code works as expected now, but would be glad to get some feedback. Maybe you find the approach only stupid, think this can be made much smarter...

    And there is on thing I don't know how to check:

    The documentation is generated by "getcommands.js" - I tried change this, too, but how to check?!?
  • ADVERTISEMENT

Topic summary

The discussion centers on optimizing the configuration page of an IoT device, specifically reducing its size from approximately 90kB to 8kB by utilizing JavaScript instead of static HTML. The OpenBeken project serves as a primary example, demonstrating how dynamic content generation can enhance loading speeds across various platforms. Participants share their experiences with different modules, such as the LN882H and issues encountered with the BK7231, particularly in Firefox. Suggestions for further optimization include reducing whitespace, reusing code for creating elements, and improving the visibility of channel fields based on user selections. The conversation also touches on the implications of optimization flags in Makefiles and the potential for future enhancements in the code structure.
Summary generated by the language model.
ADVERTISEMENT