What does the "weights" do in mgcv:gam? And how to put weights in gam? In generalized linear model we can put weights so that glm function can work faster. However for generalized additive models, in mgcv:gam we also can put weights. But I'm not sure whether this works in the similar way! Or how does it work? Or if it doesn’t work in that way then what is the procedure for putting weighs in GAM?

weights works in the same way for gam() and it does for glm() - GAMs fitted by gam() and bam() are really just fancy GLMs, and when the models contain smooths then they are fitted with a penalised version of the algorithm used to fit GLMs.
I wouldn't recommend using bootstrapping with GAMs however; non-parametric bootstrapping can lead to over smoothing because of the repeated observations of some samples in each bootstrap sample, and parametric bootstrapping of models is incredibly time consuming for GAMs and we can usually do just as well with posterior simulation.
